package informed.samples;

import informed.io.ReadSparseMatrix;

import java.util.ArrayList;

import cern.colt.matrix.DoubleMatrix2D;

public class MatrixCellValue implements Sample{
	
	public int i;
	public int j;
	public double x;
	
	public static ArrayList<Sample> loadSamples(String file){
		ReadSparseMatrix reader = new ReadSparseMatrix();
		DoubleMatrix2D X = reader.read(file);
		ArrayList<Sample> samples = new ArrayList<Sample>();
		for(int i = 0; i < X.rows(); i++){
			for(int j = 0; j < X.columns(); j++){
				MatrixCellValue s = new MatrixCellValue();
				s.i = i;
				s.j = j;
				s.x = X.getQuick(i, j);
				samples.add(s);
			}
		}
		return samples;
	}
	
	public String toString(){
		return "("+i+","+j+")=>"+x;
	}

}
